package Java_IO;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

/**
 * @author shy_black
 * @date 2019/3/20 12:42
 * @Description:
 * 内存流的输出
 *
 */
public class 内存流 {
    public static void main(String[] args) throws  Exception{
        String str = "hello...";
        //取得终端对象以及输入输出流
        ByteArrayInputStream byteArrayInputStream =
                new ByteArrayInputStream(str.getBytes());
        ByteArrayOutputStream byteArrayOutputStream =
                new ByteArrayOutputStream();
        //输入输出操作
        int len = 0;
        while((len = byteArrayInputStream.read()) != -1) {
            byteArrayOutputStream.write(len);
        }
        //输出内存内容
        System.out.println(byteArrayOutputStream);
        //关闭流
        byteArrayInputStream.close();
        byteArrayOutputStream.close();
    }
}
